package com.googlecode.perfectable.visuable.parse;

import com.googlecode.perfectable.visuable.renderer.ElementRenderer;
import com.googlecode.perfectable.visuable.renderer.VisualRenderer;

final class StructureCheckingElementRenderer implements ElementRenderer {

	private final ElementStructure structure;

	public StructureCheckingElementRenderer(ElementStructure structure) {
		this.structure = structure;
	}

	@Override
	public void attribute(String name, String value) {
		this.structure.assertAttribute(name, value);
	}

	@Override
	public void raw(String text) {
		this.structure.assertRaw(text);
	}

	@Override
	public VisualRenderer children() {
		return new StructureCheckingVisualRenderer(this.structure.children());
	}

	@Override
	public void close() {
		this.structure.assertCleared();
	}

}